package Test;

import java.util.Random;
import java.util.Scanner;

//猜数字游戏
public class Main {
    public static void main(String[] args) {
        //数组简单练习
        /*int[] arr = {1,2,3,4,5,6,7,8};
        for (int i = 0;i < 8; i++)
        {
            System.out.print(arr[i]+" ");
        }*/

        boolean bool = true;
        Random r = new Random();
        Scanner sc = new Scanner(System.in);
        do {
            int chose = 0;
            System.out.println("输入1继续游戏，输入0退出游戏");
            chose = sc.nextInt();
            switch (chose)
            {
                case 0:
                {
                    bool = false;
                    break;
                }
                case 1: {
                    System.out.println("开始游戏");
                    System.out.println("请猜测1-100的数字：");
                    int data = r.nextInt(100) + 1;
                    while (true) {
                        int n = sc.nextInt();
                        if (n > data) {
                            System.out.println("猜大了");
                        } else if (n < data) {
                            System.out.println("猜小了");
                        } else {
                            System.out.println("猜对了");
                            break;
                        }
                    }
                }
            }
        }while(bool);
    }
}

//随机数
/*public class Main {
    public static void main(String[] args) {
        Random r = new Random();

        for(int i = 0; i <= 10; i++)
        {
            int data = r.nextInt(10);
            System.out.print(data+" ");
        }
    }
}*/
